/*
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */

/**
 * @param {ListNode} head
 * @return {boolean}
 */
function ListNode (val) {
  this.val = val;
  this.next = null;
}
var hasCycle = function (head) {
  let map = new Map()
  while (head) {
    if (map.has(head)) return true
    map.set(head, true) // 存储地址值的引用
    head = head.next
  }
  return false
};
console.log();